/*
 * Copyright (C) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the 'License');
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an 'AS IS' BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

export function display(iterable) {
  const results = [];
  for (let each of iterable) {
    results.push(each);
  }
  return results;
}

export const testIterables = {
  numberSet: new Set([1, 2, 3]),

  userMap: new Map([
    [1, { name: 'Alice', age: 30 }],
    [2, { name: 'Bob', age: 25 }]
  ]),
};

export function displayAll(iterables) {
  const results = [];
  for (const [name, iterable] of Object.entries(iterables)) {
    results.push(`Iterating ${name}:`);
    for (const item of iterable) {
      results.push(JSON.stringify(item));
    }
  }
  return results;
}

export const simpleObject = {
  name: "Alice",
  age: 30,
  job: "Engineer"
};

export function printObjectKeys(obj) {
  const keys = [];
  for (const key in obj) {
    keys.push(key);
  }
  return keys;
}